package org.company.saturn.hadoop.vo;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;

/**
 * int 对
 * @author hucw
 *
 */
public class IntPair implements WritableComparable<IntPair> {
	
	private int first;
	
	private int second;
	
	public int getFirst() {
		return this.first;
	}
	
	public int getSecond() {
		return this.second;
	}
	
	public void set(int left,int right) {
		this.first = left;
		this.second = right;
	}

	@Override
	public void write(DataOutput out) throws IOException {
		out.writeInt(first);
		out.writeInt(second);
	}

	@Override
	public void readFields(DataInput in) throws IOException {
		this.first = in.readInt();
		this.second = in.readInt();
	}

	@Override
	public int compareTo(IntPair o) {
		if(first != o.getFirst()) {
			return first < o.first ? -1 : 1;
		} else if(second != o.getSecond()) {
			return this.getSecond() < o.getSecond() ? -1 : 1;
		}
		return 0;
	}
}
